package com.guangyunl.d_var;
//需求二:
//        n个字符串进行拼接，每一个字符串之间使用某字符进行分隔，如果没有传入字符串，那么返回空字符串""
public class Demo03Var {
    public static void main(String[] args) {
        String result = concat03("-","张三", "李四", "王五" , "赵六");
        System.out.println("result = " + result);
        System.out.println("===========================");
        System.out.println("不传入字符串=" + concat03("",""));
    }

    public static String concat03(String regex, String...s){
        String str = "";
        for (int i = 0; i < s.length; i++) {
            if (i == s.length-1){
                str+=s[i];
            }else{
                str+=s[i] + regex;
            }
        }
        return str;
    }
}
/*
result = 张三-李四-王五-赵六
===========================
不传入字符串=
 */